<template>
  <div>
    <h1>this指向</h1>
  </div>
</template>

<script setup>
const obj = {
  getArrow() {
    return () => {
      console.log(this === obj)
    }
  }
}
const obj2 = {
  getArrow() {
    return function () {
      console.log(this, 'this')
      console.log(this === obj2.getArrow)
    }
  }
}
const obj3 = {
  getArrow() {
    console.log(this, 'this3')
  }
}

function doFoo() {
  console.log(this, 'this2')
  foo()
}
function foo() {
  console.log(this, 'this3')
}
var obj4 = {
  a: 1,
  doFoo: doFoo
}
var a = 2
obj4.doFoo()
// obj.getArrow()()
// obj2.getArrow()()
// obj3.getArrow()
</script>

<style lang="scss" scoped></style>
